package com.sbk.xuanliu.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.sbk.xuanliu.result.ResultData;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 孙壁凯
 * @Date: 2021/11/03/16:07
 * @Description: WebUtils是用于操作页面信息的类
 */
public class WebUtils {

    /**
     * 对象封装为json,并返回页面
     */
    public static void writeJson(HttpServletResponse response, ResultData resultData) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write(JSON.toJSONString(resultData, SerializerFeature.WriteMapNullValue));
    }

}
